package com.naruto.thinkmgr.configuration;

import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
import com.naruto.thinkmgr.web.MyErrorController;
import org.springframework.boot.autoconfigure.web.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.dialect.IDialect;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
import org.thymeleaf.templateresolver.TemplateResolver;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Configuration
//@ConditionalOnWebApplication
//@ConditionalOnClass({Servlet.class, DispatcherServlet.class})
//@AutoConfigureBefore(WebMvcAutoConfiguration.class)
//@EnableConfigurationProperties(ResourceProperties.class)
public class MvcConfiguration {

//    public MvcConfiguration(
//            ServerProperties serverProperties) {
//        this.serverProperties = serverProperties;
//    }
//
//
//    @Autowired(required = false)
//    private List<ErrorViewResolver> errorViewResolvers;
//
//    private final ServerProperties serverProperties;


//    @Bean
//    public MyErrorController basicErrorController(ErrorAttributes errorAttributes) {
//        return new MyErrorController(errorAttributes, serverProperties.getError(),
//                errorViewResolvers);
//    }
    @Bean
    public MyErrorController basicErrorController(ErrorAttributes errorAttributes, ServerProperties serverProperties, List<ErrorViewResolver> errorViewResolvers) {
        return new MyErrorController(errorAttributes, serverProperties.getError(),
                errorViewResolvers);
    }

    /**
     * 主要用作thymeleaf模板引擎中加入shiro标签
     * @param
     * @return
     */
    @Bean
    public ShiroDialect shiroDialect() {
        return new ShiroDialect();
    }
}
